import { createSlice } from "@reduxjs/toolkit";

export const ticketSlice = createSlice({
  name: "ticket",
  initialState: {
    history: [],
  },
  reducers: {
    saveCity(state, action) {
      state.history.unshift(action.payload);
      const set = new Set(state.history);
      state.history = Array.from(set);
    },
  },
});
// 每个 case reducer 函数会生成对应的 Action creators
export const { saveCity } = ticketSlice.actions;

export default ticketSlice.reducer;
